package org.wishwork.api.inventory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wishwork.api.inventory.count.InventoryCountApi;
import org.wishwork.api.inventory.count.InventoryCountRequest;
import org.wishwork.api.inventory.count.InventoryCountResponse;
import org.wishwork.api.inventory.query.InventoryQueryApi;
import org.wishwork.api.inventory.query.InventoryQueryRequest;
import org.wishwork.api.inventory.query.InventoryQueryResponse;
import org.wishwork.api.inventory.upload.InventoryUploadApi;
import org.wishwork.api.inventory.upload.InventoryUploadResponse;
import org.wishwork.api.inventory.upload.request.InventoryUploadRequest;
import org.wishwork.context.Context;

import java.util.List;

/**
 * @description: 库存API
 * @author: WangYX
 * @create: 2022-04-06 11:01
 * @Version: 1.0.0
 **/

public class InventoryApi {

    private static final Logger log = LoggerFactory.getLogger(InventoryApi.class);

    private Context context;

    private final InventoryQueryApi inventoryQueryApi;

    private final InventoryCountApi inventoryCountApi;

    private final InventoryUploadApi inventoryUploadApi;

    public InventoryApi(Context context) {
        this.context = context;
        this.inventoryQueryApi = new InventoryQueryApi(context);
        this.inventoryCountApi = new InventoryCountApi(context);
        this.inventoryUploadApi = new InventoryUploadApi(context);
    }

    /**
     * 库存查询
     *
     * @param inventoryQueryRequest
     * @return
     * @throws Exception
     */
    public List<InventoryQueryResponse> query(InventoryQueryRequest inventoryQueryRequest) throws Exception {
        return this.inventoryQueryApi.business(inventoryQueryRequest);
    }

    /**
     * 库存盘点查询
     *
     * @param inventoryCountRequest
     * @return
     * @throws Exception
     */
    public List<InventoryCountResponse> count(InventoryCountRequest inventoryCountRequest) throws Exception {
        return this.inventoryCountApi.business(inventoryCountRequest);
    }

    /**
     * 新建盘点单
     *
     * @param inventoryUploadRequest
     * @return
     * @throws Exception
     */
    public InventoryUploadResponse upload(InventoryUploadRequest inventoryUploadRequest) throws Exception {
        return this.inventoryUploadApi.business(inventoryUploadRequest);
    }


}
